package com.fire.control.system.module.system.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fire.control.system.entity.Resource;
import com.fire.control.system.entity.SystemLog;
import com.fire.control.system.module.system.dao.SystemLogMapper;
import com.fire.control.system.module.system.service.ResourceService;
import com.fire.control.system.module.system.service.SystemLogService;

@Service("systemLogService")
public class SystemLogServiceImpl implements SystemLogService{
	
	@Autowired SystemLogMapper systemLogMapper;
	@Autowired ResourceService resourceService;
	
	public void addSystemLog(String userId,String url){
		Resource resource = resourceService.getResourceByUrl(url);
		if(resource!=null){
			SystemLog systemLog = new SystemLog();
			systemLog.setMonitorTargetId(userId);
    		systemLog.setResourceId(resource.getId());
    		systemLog.setMonitorContext(resource.getResourceDesc());
    		systemLog.setMonitorMethod(resource.getName());
    		systemLogMapper.addSystemLog(systemLog);
    	}
	}
	
}
